{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Simulating circuits with the stabilizer formalism (Gottesman-Knill Theorem)\n",
    "\n",
    "This is a very simple notebook to show that circuits which only use gates from the set $\\{H, X, CNOT, S\\}$ can be simulated efficiently on classical computers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Importing standard Qiskit libraries\n",
    "from qiskit import QuantumCircuit, execute, Aer, IBMQ\n",
    "\n",
    "# Loading your IBM Q account(s)\n",
    "provider = IBMQ.load_account()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We create a highly entangled state on 1000 qubits. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "n = 1000\n",
    "circ = QuantumCircuit(n,n)\n",
    "\n",
    "circ.h(0)\n",
    "for i in range(1,n):\n",
    "    circ.cx(0,i)\n",
    "\n",
    "circ.measure(range(n),range(n))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We are able to simulate it classically because we are only using the $H$ and $CNOT$ gates. Qiskit automatically selects the stabilizer method for the simulation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "backend = Aer.get_backend(\"qasm_simulator\")\n",
    "job = execute(circ,backend)\n",
    "print(job.result().get_counts())"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
